package helloworld.rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.ExportException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author wuyang
 * @version 1.0 2009.3.22
 */
public class HelloworldServer {

	public static void main(String[] args) {

		String host = "192.168.1.108";

		Helloworld helloworld = null;
		try {
			helloworld = new HelloworldImp();
			LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
			Naming.rebind("rmi://" + host + ":" + Registry.REGISTRY_PORT
					+ "/Hello", helloworld);
		} catch (MalformedURLException ex) {
			Logger.getLogger(HelloworldServer.class.getName()).log(
					Level.SEVERE, null, ex);
		} catch (ExportException ex) {
			System.out.println("Can't open two games in a time!");
			System.exit(0);
		} catch (RemoteException ex) {
			Logger.getLogger(HelloworldServer.class.getName()).log(
					Level.SEVERE, null, ex);
		}
	}
}